Skip to content

1.6. VS Code

What is Visual Studio Code?

Visual Studio Code (VS Code) is a free, open-source code editor from Microsoft that has become the de-facto standard for modern software development. It combines the simplicity of a text editor with powerful Integrated Development Environment (IDE) features. Its lightweight nature, combined with a vast ecosystem of extensions, makes it an ideal choice for Python and MLOps development, where versatility and performance are key.

Why is VS Code the right choice for MLOps?

For MLOps professionals, a powerful and adaptable editor is non-negotiable. VS Code excels by providing:

  • High-Performance Editing: Get intelligent code completion with IntelliSense, seamless code navigation, and immediate feedback without the heavy footprint of traditional IDEs.
  • Unmatched Extensibility: The Marketplace lets you tailor your environment precisely for MLOps tasks, with extensions for Python, Docker, Kubernetes, cloud platforms, and more.
  • Seamless Workflow Integration: Manage your entire workflow in one place. Use the Integrated Terminal to run experiments, Source Control to manage code with Git, and powerful Debugging Tools to troubleshoot models and pipelines.
  • Remote Development: Connect to remote servers, containers, or the Windows Subsystem for Linux (WSL) as if they were local. This is critical for training models on powerful cloud instances or ensuring consistent development environments.

How do you install VS Code?

Installing VS Code is straightforward:

  1. Navigate to the official VS Code website.
  2. Download the appropriate installer for your operating system (Windows, macOS, or Linux).
  3. Run the installer and follow the on-screen instructions.

Where can you master VS Code?

To accelerate your learning curve, explore these excellent resources:

Which extensions are essential for MLOps?

A stock VS Code editor is powerful, but extensions unlock its true potential for MLOps. We've curated a list of extensions, categorized into tiers, to build a professional-grade development environment. You can install them directly from the VS Code Marketplace.

Which VS Code extensions should you install for MLOps?

This section lists the extensions you can install from VS Code Marketplace:

A Tier: The Must

B Tier: The Great

C Tier: The Good

How should you configure VS Code for MLOps?

Keep project settings small and share the settings needed to run the same tools:

{
  "python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python",
  "python.testing.pytestEnabled": true,
  "python.testing.unittestEnabled": false,
  "[python]": {
    "editor.defaultFormatter": "charliermarsh.ruff",
    "editor.formatOnSave": true,
    "editor.codeActionsOnSave": {"source.organizeImports": "explicit"}
  }
}

On Windows, select .venv\Scripts\python.exe. Install Ruff, ty, and Jupyter extensions, and select the same .venv as the notebook kernel. Keep normal workspace trust and confirmation settings. The reference workspace contains the maintained project configuration.

How do you create project-specific settings?

While user settings apply globally, you can define settings specific to a project to ensure consistency across a team. This is a core MLOps practice, as it standardizes the development environment for anyone who clones the repository.

  1. Create a folder named .vscode at the root of your project.
  2. Inside this folder, create a file named settings.json.
  3. Add any project-specific configurations to this file.

VS Code will automatically apply these settings when you open the project folder.

Example .vscode/settings.json:

This configuration automatically enables the Ruff formatter and turns on Pytest for any team member opening the project.

{
    // Define Python-specific settings for this project
    "[python]": {
        "editor.defaultFormatter": "charliermarsh.ruff",
        "editor.codeActionsOnSave": {
            "source.organizeImports": "explicit"
        }
    },
    // Enable the project's chosen testing framework
    "python.testing.pytestEnabled": true
}

How do you connect the Jupyter extension to your uv environment?

To ensure VS Code's Jupyter extension uses the correct packages from your uv-managed environment, you must point it to the right Python interpreter. This enables features like IntelliSense and debugging to work seamlessly within your notebooks.

  1. Open Your Project: Launch VS Code from the root of your project directory (the one containing pyproject.toml and .venv).
  2. Select the Interpreter:
    • Open the Command Palette (Ctrl+Shift+P or Cmd+Shift+P).
    • Type and select Python: Select Interpreter.
    • Choose the interpreter associated with your project. VS Code usually recommends the correct one, often labeled with .venv and identified as a virtual environment.
  3. Verify the Connection:
    • Create or open a Jupyter Notebook (.ipynb file).
    • Click the kernel selector in the top-right corner.
    • Confirm that the selected kernel points to the same .venv Python interpreter you chose in the previous step.

Now, any packages you add to your project with uv add <package-name> will be immediately available in your Jupyter notebooks.

Additional Resources